import 'package:flutter/material.dart';
import 'package:tender_flutter/constant/app_constant.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/style/font_style.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';
import 'package:tender_flutter/widgets/base_appbar.dart';
import 'package:tender_flutter/widgets/round_tab_indicator.dart';

import 'market_publish_form_page.dart';

class MarketPulishPage extends StatefulWidget {
  @override
  _MarketPulishPageState createState() => _MarketPulishPageState();
}

class _MarketPulishPageState extends State<MarketPulishPage>
    with TickerProviderStateMixin {
  List<String> _tagTypes;

  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tagTypes = ["供应发布", "需求发布"];

    _tabController = TabController(
      length: _tagTypes.length,
      vsync: this,
    );
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: ThemeColors.colorWhite,
        appBar: _initAppBar(),
        body: _initBody());
  }

  /// 导航
  Widget _initAppBar() {
    return BaseAppBar(context, Text("供需发布", style: FonStyle.navTextStyle()));
  }

  /// 内容体
  Widget _initBody() {
    return Container(
      width: double.infinity,
      child: Column(
        children: [
          Container(
              height: ScreenAdapter.height(80),
              child: TabBar(
                onTap: (index) {},
                indicator: RoundUnderlineTabIndicator(
                    borderSide: BorderSide(
                  width: 5,
                  color: ThemeColors.colorType6,
                )),
                labelStyle: TextStyle(
                  fontSize: ScreenAdapter.sp(35),
                  fontWeight: FontWeight.w600,
                ),
                unselectedLabelStyle: TextStyle(
                  fontSize: ScreenAdapter.sp(35),
                  fontWeight: FontWeight.w600,
                ),
                labelColor: ThemeColors.colorType8,
                unselectedLabelColor: ThemeColors.colorType7,
                controller: _tabController,
                tabs: _tagTypes
                    .map((e) => Tab(
                          child: Container(
                            child: Text(e),
                            padding: const EdgeInsets.only(
                              bottom: 0,
                            ),
                          ),
                        ))
                    .toList(),
              )),
          Expanded(
              child: TabBarView(
            controller: _tabController,
            children: <Widget>[
              MarketPublishFormPage(marketType: AppConstant.MARKET_SUPPLY),
              MarketPublishFormPage(marketType: AppConstant.MARKET_DEMAND),
            ],
          ))
        ],
      ),
    );
  }
}
